<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    const curry = function (fn) {
      const args = []
      return function () {
        if (arguments.length === 0) {
          return fn.apply(this, args)
        } else {
          [].push.apply(args, arguments)
          return arguments.callee
        }
      }
    }
    const cost = function () {
      let money = 0
      for (let i = 0; i < arguments.length; i++) {
        money += arguments[i]
      }
      return money
    }
    const a = curry(cost)
    a(200)
    a(400)
    a(600)
    a(800)
    console.log(a())
  </script>
</body>

</html>
